max_range = 10 ** 5 + 1
p = [1] * max_range
st = []
for i in range(2, max_range):
    if p[i] == 1:
        st.append(i)
    for num in st:
        if num * i < max_range:
            p[num * i] = num
            if i % num == 0:
                break
        else:
            break

import collections
import math


class Solution(object):
    def countAnagrams(self, s):
        s = s.split(' ')
        base = 10 ** 9 + 7
        ans = 1

        def cal(word):
            c = collections.Counter(word)
            t = collections.defaultdict(int)
            total = 0
            for key in c:
                num = c[key]
                total += num
                for i in range(2, num + 1):
                    now = i
                    while p[now] > 1:
                        t[p[now]] -= 1
                        now = now // p[now]
                    t[now] -= 1
            for i in range(2, total + 1):
                now = i
                while p[now] > 1:
                    t[p[now]] += 1
                    now = now // p[now]
                t[now] += 1
            ans = 1
            for key in t:
                if t[key] > 0:
                    ans = ans * pow(key, t[key], base) % base
            return ans

        for word in s:
            ans = ans * cal(word) % base
        return ans


data = Solution()
s = "ttooaaaaaaaaaferwerwerewr hot"
print(data.countAnagrams(s))